<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    //    String()
    var s = '   abc  ';

    String.prototype.myTrim = function () {
        var reg = /^\s*(.*?)\s*$/;
        var s = this.valueOf();
        var r = s.replace(reg, "$1");
        return r;
    }

    var r = s.myTrim();
    console.log(r);

    var s2 = ' 你好  '
    var r2 = s2.myTrim();
    console.log(r2);
    console.log(s2);


    //Array.prototype.myForEach
    //Array.prottype.myMap
</script>
</body>
</html>